import Request from 'luch-request'

const http = new Request();

/**
* @description 修改全局默认配置
* @param {Function}   
*/
http.setConfig((config) => { /* config 为默认全局配置*/
    config.baseURL = 'https://log.nieanshow.cn/wp-json/wp/v2'; /* 根域名 */
    return config
})
http.interceptors.request.use((config) => {
  return config
}, config => {
  return Promise.reject(config)
})

http.interceptors.response.use((response) => {
  return response
}, (response) => {
  if(response.data.code == 'rest_post_invalid_page_number'){
	  return Promise.reject(response)
  }
  uni.showToast({
	 icon:'none',
	 title:response.data.message,
	 duration:3500
  })
  return Promise.reject(response)
})

export default http